﻿using System;
using Dune.Common.Utils;

namespace Dune.Business.Domain
{
    [Serializable]
    public class BaseFilter : ICloneable
    {
        private int maxLength = 40;

        public int MaxLength
        {
            get { return maxLength; }
            set { maxLength = value; }
        }

        public virtual void Clear()
        {
            Type selfType = this.GetType();
            ReflectionUtils.CopyNoPuplicFields(Activator.CreateInstance(selfType), this, true);
        }

        public virtual object Clone()
        {
            Type selfType = this.GetType();
            object ret = Activator.CreateInstance(selfType);
            ReflectionUtils.CopyNoPuplicFields(this, ret, true);
            return ret;
        }

        public void Copy(BaseFilter to)
        {
            ReflectionUtils.CopyNoPuplicFields(this, to, true);
        }

        public override bool Equals(object obj)
        {
            if (this == obj) return true;
            return ReflectionUtils.EqualsAllFields(this, obj);
        }

        public virtual int GetMaxLength()
        {
            return MaxLength;
        }


    }
}
